﻿package 
{
    import ChatDownBox.*;

    public class ChatDownBox extends DownBoxBase
    {
        private var _onSendData:Function;
        private var _onPlayerData:Object;
        private var _boxWidth:int = 86;
        private var _mcBox:ChatMcBox;
        private var _mcBoxList:Array;

        public function ChatDownBox() : void
        {
            this._onSendData = new Function();
            return;
        }// end function

        public function set onSendData(param1:Function) : void
        {
            this._onSendData = param1;
            return;
        }// end function

        public function set onPlayerData(param1:Object) : void
        {
            this._onPlayerData = param1;
            return;
        }// end function

        public function set getBoxList(param1:Array) : void
        {
            this.renderBox(param1);
            return;
        }// end function

        public function set boxWidth(param1:int) : void
        {
            this._boxWidth = param1;
            return;
        }// end function

        private function renderBox(param1:Array) : void
        {
            var obj:Object;
            var list:* = param1;
            this.clearBox();
            this._mcBoxList = [];
            var len:* = list.length;
            var i:int;
            while (i < len)
            {
                
                obj = list[i];
                this._mcBox = new ChatMcBox();
                this._mcBox.text = obj.label;
                this._mcBox.mcData = obj;
                this._mcBox.mcWidth = this._boxWidth;
                this._mcBox.buttonMode = true;
                this._mcBox.boxId = i;
                this._mcBox.y = i * this._mcBox.height;
                this._mcBox.x = 0.5;
                this._mcBoxList.push(this._mcBox);
                addChild(this._mcBox);
                this._mcBox.onSendData = function (param1:Object, param2:int) : void
            {
                _onSendData(param1, _onPlayerData);
                _mcBoxList[param2].isPitch = false;
                return;
            }// end function
            ;
                i = (i + 1);
            }
            return;
        }// end function

        private function clearBox() : void
        {
            if (this._mcBoxList == null)
            {
                return;
            }
            var _loc_1:* = this._mcBoxList.length;
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1)
            {
                
                this._mcBoxList[_loc_2].clear();
                removeChild(this._mcBoxList[_loc_2]);
                this._mcBoxList[_loc_2] = null;
                _loc_2 = _loc_2 + 1;
            }
            this._mcBoxList = null;
            return;
        }// end function

        public function clear() : void
        {
            this.clearBox();
            this._onPlayerData = null;
            return;
        }// end function

    }
}
